package com.factory;

import com.dao.Calculator;
import com.dao.Impl.CalculatorAddImpl;
import com.dao.Impl.CalculatorDivImpl;
import com.dao.Impl.CalculatorMulImpl;
import com.dao.Impl.CalculatorSubImpl;


public class CalculatorFactory {
    /**
     * 创建实例工厂方法
     * @return
     */
    public static Calculator getInstance(String key) {
        switch (key) {
            case "+":
                return new CalculatorAddImpl();
            case "-":
                return new CalculatorSubImpl();
            case "/":
                return new CalculatorDivImpl();
            case "*":
                return new CalculatorMulImpl();
            default:
                return null;
        }
    }
}
